﻿using System.Collections;
using System.Collections.Generic;

namespace Istace.Framework.Mapping.Core.Interfaces
{
    /// <summary>
    /// Interface for the service used to map object from different types
    /// </summary>
    public interface IMapperService
    {
        /// <summary>
        /// Register a IMapper
        /// </summary>
        /// <param name="mapper">mapper instance</param>
        void Register(IMapper mapper);

        /// <summary>
        /// Register a IMapper which implement the given MappingTuple
        /// </summary>
        /// <param name="mapper">Mapper Instance</param>
        /// <param name="tuple">Mapping tuple implmented by the mapper</param>
        void Register(IMapper mapper, IMappingTuple tuple);

        /// <summary>
        /// Register a IMapper which implement the given MappingTuple
        /// </summary>
        /// <param name="mapper">Mapper Instance</param>
        /// <param name="tuple">Mapping tuple implmented by the mapper</param>
        bool TryRegister(IMapper mapper, IMappingTuple tuple);

        /// <summary>
        /// Map the TSource type source object to the TDestination type
        /// </summary>
        /// <typeparam name="TSource">TSource type</typeparam>
        /// <typeparam name="TDestination">TDestination type</typeparam>
        /// <param name="source">Object to convert of TSsource type</param>
        /// <returns>Converted object to TDestination type</returns>
        TDestination Map<TSource, TDestination>(TSource source);

        /// <summary>
        /// Map the TSource source object to the TDestination type
        /// </summary>
        /// <typeparam name="TDestination">TDestination type</typeparam>
        /// <param name="source">Object to convert</param>
        /// <returns>Converted object to TDestination type</returns>
        TDestination Map<TDestination>(object source);

        /// <summary>
        /// Map the TSource type source object list to the TDestination type
        /// </summary>
        /// <typeparam name="TSource">TSource type</typeparam>
        /// <typeparam name="TDestination">TDestination type</typeparam>
        /// <param name="source">Object list to convert of TSource type to TDestination type</param>
        /// <returns>Converted list of object to TDestination type</returns>
        IEnumerable<TDestination> MapList<TSource, TDestination>(IEnumerable<TSource> source);

        /// <summary>
        /// Map the TSource object list to the TDestination type
        /// </summary>
        /// <typeparam name="TDestination">TDestination type</typeparam>
        /// <param name="source">Object list to convert of TSource type to TDestination type</param>
        /// <returns>Converted list of object to TDestination type</returns>
        IEnumerable<TDestination> MapList<TDestination>(IEnumerable source);
    }
}
